
import promiseUtils from "./promise_utils"


/**
 * 检测当前设备是否支持音视频通话
 */
const deviceDetectionUtils = () :Promise<boolean> => {
  return promiseUtils<boolean>((resolve: (result: boolean) => void, reject: (error: any) => void) => {
    if (!navigator || typeof navigator != 'object' || !navigator.mediaDevices) {
      reject (!navigator ? 'navigator not found!' : `navigator.mediaDevices: ${navigator.mediaDevices} not is getUserMedia`)
      return
    } 
  
    const status = 'mediaDevices' in navigator && 'getUserMedia' in navigator.mediaDevices
    resolve(status)
  })
}




export default deviceDetectionUtils